package io.acm.modules.app.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.acm.common.vo.AppUserResponse;
import io.acm.common.vo.StudentResponse;
import io.acm.modules.admin.entity.AppUserEntity;
import io.acm.modules.app.dao.FollowDao;
import io.acm.modules.app.dao.StudentDao;
import io.acm.modules.app.entity.FollowEntity;
import io.acm.modules.app.entity.StuFileEntity;
import io.acm.modules.app.entity.StudentEntity;
import io.acm.modules.app.service.FollowService;
import io.acm.modules.app.service.StuFileService;
import io.acm.modules.app.service.StudentService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("studentService")
public class StudentServiceImpl extends ServiceImpl<StudentDao, StudentEntity> implements StudentService {
    @Autowired
    StuFileService stuFileService;

    @Override
    public void studentTostufIle(StudentEntity student) {
        StuFileEntity stuFile = new StuFileEntity();
        stuFile.setSId(student.getSId());
        stuFile.setSex(student.getSex());
        stuFile.setEmail(student.getEmail());
        stuFile.setMajor(student.getMajor());
        stuFile.setUserName(student.getUserName());
        stuFile.setClassName(student.getClassName());
        stuFile.setCollege(student.getCollege());
        stuFile.setPhone(student.getPhone());

        LambdaQueryWrapper<StuFileEntity> queryWrapper = new LambdaQueryWrapper();
        queryWrapper.eq(StuFileEntity::getSId,student.getSId());
        int count = stuFileService.count(queryWrapper);

        if(count==0) stuFileService.save(stuFile);
        else stuFileService.updateById(stuFile);
    }

//    @Override
//    public StudentResponse getStudentInfo(StudentEntity student) {
//        StudentResponse response = new StudentResponse();
//        BeanUtils.copyProperties(student, response);
//        //.....todo
//        return response;
//    }
}
